package com.example.windowdemo.window;

import android.content.Context;
import android.util.Log;
import android.view.KeyEvent;

/**
 * @author: njb
 * @date: 2023/7/31 14:07
 * @desc:
 */
public class WindowCallClean extends Window{
    public WindowCallClean(Context context) {
        super(context);
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        long startTime = System.currentTimeMillis();
        Log.d("keyEvent:" , "keyEvent.getCode" + event.getKeyCode());
        //返回键关闭窗口，取消事件捕获
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            hide();
            return true;
        }
        return super.dispatchKeyEvent(event);
    }
}
